<?php if (isset($error)) { ?>
<div class="warning"><?php echo $error; ?></div>
<?php } ?>
<form method="post" enctype="multipart/form-data" autocomplete="off">
    <div id="payment">
	<h2><?php echo $text_creditcard; ?></h2>
    <table class="form">
      <tr>
        <td><span class="required">*</span>&nbsp;<?php echo $entry_cc_type; ?></td>
        <td>
		  <select name="cc_type">
			  <?php foreach ($cards as $card) { ?>
			  <option value="<?php echo $card['value']; ?>"  <?php echo (@$cc_type_val == $card['value']) ? ' selected="selected"' : '';?>>
			  <?php echo $card['text']; ?></option>
			  <?php } ?>
		  </select>
        </td>
      </tr>
      <tr>
        <td><span class="required">*</span>&nbsp;<?php echo $entry_cc_name; ?></td>
        <td><input type="text" name="cc_name" value="<?php echo $cc_name_val; ?>"></td>
      </tr>
      <tr>
        <td><span class="required">*</span>&nbsp;<?php echo $entry_cc_number; ?></td>
        <td><input type="text" name="cc_number" value="<?php echo $cc_number_val; ?>"></td>
      </tr>
      <tr>
        <td><span class="required">*</span>&nbsp;<?php echo $entry_cc_expire; ?></td>
        <td>
		
		<select name="cc_month">
          <?php foreach ($months as $month) { ?>
          <option value="<?php echo $month['value']; ?>"  <?php echo (@$cc_month_val == $month['value']) ? ' selected="selected"' : '';?>>
			  <?php echo $month['text']; ?>
          <?php } ?>
        </select>
		/
        <select name="cc_year">
          <?php foreach ($year_expire as $year) { ?>
          <option value="<?php echo $year['value']; ?>"  <?php echo (@$cc_year_val == $year['value']) ? ' selected="selected"' : '';?>>
			  <?php echo $year['text']; ?>
		  <?php } ?>
        </select>
        </td>
      </tr>
      <tr>
        <td><span class="required">*</span>&nbsp;<?php echo $entry_cc_cvv; ?></td>
        <td><input type="text" name="cc_cvv" size="3" value="<?php echo $cc_cvv_val; ?>"></td>
      </tr>
      <?php if (isset($solo_support) && $solo_support) { ?>
      <tr>
        <td><?php echo $entry_cc_startdate; ?></td>
        <td><input type="text" name="cc_startdate" size="12" value="<?php echo $cc_startdate_val; ?>"></td>
        <td><?php echo $this->language->get('extra_cc_startdate'); ?></td>
      </tr>
      <tr>
        <td><?php echo $entry_cc_issuenum; ?></td>
        <td><input type="text" name="cc_issuenum" size="12" value="<?php echo $cc_issuenum_val; ?>"></td>
        <td><?php echo $this->language->get('extra_cc_issuenum'); ?></td>
      </tr>
      <?php } ?>
    </table>
  </div>
</form>
<div class="buttons">
  <div class="right"><a onclick="confirmSubmit();" class="button"><span><?php echo $button_confirm; ?></span></a></div>  
</div>

<script type="text/javascript"><!--
function confirmSubmit() {
	$.ajax({
		type: 'POST',
		url: 'index.php?route=payment/offline_cc/confirm',
		data: $('#payment :input'),
		dataType: 'json',		
		beforeSend: function() {
			$('.attention').remove();
			$('#button-confirm').attr('disabled', true);
			$('#payment').before('<div class="attention"><img src="catalog/view/theme/default/image/loading.gif" alt="" /> <?php echo "Please wait"; ?></div>');
		},
		success: function(json) {
			if (json['error']) {
				$('.attention').remove();
				$('#payment').before('<div class="attention">' + json['error'] + '</div>');		
				$('#button-confirm').attr('disabled', false);
			}
			
			if (json['success']) {
				location = json['success'];
			}
		}
	});
}
//--></script>